package com.kb.medical.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class ESClient {

    @Bean
    public static RestHighLevelClient getClient() {
        //创建HttpHost对象
        HttpHost httpHost = new HttpHost("127.0.0.1", 9200);
//        创建RestClientBuilder
        RestClientBuilder clientBuilder = RestClient.builder(httpHost);
//        创建RestHighLevelClient
        RestHighLevelClient client = new RestHighLevelClient(clientBuilder);

        //返回
        return client;
    }


}











